<?php
// 从URL中获取sense_id参数的值
$sense_id = $_GET['sense_id'];

// 连接数据库
include('connection.php');
session_start();
$userid = $_SESSION['userid'];

$sql = "SELECT sense_name FROM sense WHERE sense_id = '$sense_id';";
$result = mysqli_query($connection, $sql);

// 将sense_id与user表中的userid一起插入到route表中
 $row = mysqli_fetch_assoc($result);
    $sense_name = $row["sense_name"];
    // 将sense_id与user表中的userid一起插入到route表中
    $sql = "INSERT INTO schedule (userid, sense_id, sense_name) VALUES ('$userid', '$sense_id', '$sense_name')";
$result = mysqli_query($connection, $sql);
if (!$result) {
    // 关闭数据库连接
    mysqli_close($connection);
    ?>
    <script>
        alert("添加失败");
        history.back();
    </script>
    <?php
} else {
    // 关闭数据库连接
    mysqli_close($connection);
    ?>
    <script>
        alert("添加成功");
        history.back();
    </script>
    <?php } ?> 